<?php 

header("content-type: text/html; charset=utf-8");

/*
 * 使用interface关键字可以声明接口，接口以及接口的成员不能有任何修饰符。
 */
interface Playable {
	function play();
}

/*
 * 使用abstract关键字可以声明抽象类和方法。
 */
abstract class Base {
    private	$header = "";
	private	$rooter = "";

	public static $StaticProperty = "父类静态属性<br/>";
	const MAX = "父类常量<br/>";

	public function __construct($header, $rooter) {
		$this->header = $header;
		$this->rooter = $rooter;
	}
	
	public function write() {
		$this->writeHeader();
		$this->writeContent();
		$this->writeRooter();
	}

    private function writeHeader() {
		echo $this->header."<br/>";
	}

    private function writeRooter() {
		echo $this->rooter."<br/>";
	}

    protected abstract function writeContent();
}

/*
 * 使用final关键字可以禁止类型或方法被重写。
 * 使用parent::在重写的方法里调用父类型的方法。
 */
final class Child extends Base implements Playable {
	public $content = "";
	public static $StaticProperty = "子类静态属性<br/>";
	const MAX = "子类常量<br/>";

	public function __construct($header, $rooter, $content) {
		parent::__construct($header, $rooter);

		$this->content = $content;
	}

    protected function writeContent() {
		echo $this->content."<br/>";
	}

	public function play() {
		echo "游戏中。。。<br/>";
	}

	public function __destruct() {
		echo "析构中";
	}
}

$child = new Child("开始", "结束", "内容");

echo get_class($child).'<br/>';
print_r(get_class_methods(get_class($child)));
echo '<br/>';
print_r(get_class_vars(get_class($child)));
echo '<br/>';
echo $child->{"play"}();
?>